class_name PlayerRunState
extends GameplayState

@onready var player: Player = $"../../../"


func _on_enter() -> void:
	player.animator.play(&"run")

	player.player_tag_manager.add_tag(player.player_tag_manager.State_Ground_Stand)
	player.player_tag_manager.add_tag(player.player_tag_manager.State_Ground_Move_Run)
	
	player.velocity = Vector2.ZERO


func _on_update(delta: float) -> void:
	player.velocity.x += player.player_input_handler.movement_input * player.player_stats.movement_speed_agument * delta
	player.velocity.x = clampf(player.velocity.x, -player.player_stats.run_speed, player.player_stats.run_speed)
	
	if player.player_input_handler.movement_input * player.face_direction < 0:
		player.flip()


func _on_exit() -> void:
	player.player_tag_manager.remove_tag(player.player_tag_manager.State_Ground_Stand)
	player.player_tag_manager.remove_tag(player.player_tag_manager.State_Ground_Move_Run)
